﻿@using KRM.Core

@using KRM.Core.Library
@model tblKRMRSDispute
@{
    var db = new KRMEntities();
    var brief = db.vWebBriefOrderItemDetails.FirstOrDefault(a => a.OrderItemID == Model.OrderItemID);
    ViewBag.ActionID = new SelectList(db.tblKRMRSDisputeActions.Where(a => a.Archived == false).OrderBy(a => a.Archived), "ActionID", "Action", Model.ActionID);
}
@Html.Partial("Partial/_MessageResult")
<div class="row-fluid">
    <div class="span3">
        <div class="span3">OrderRef</div>
        <div class="span9">
            <input type="text" class="input-block-level" id="OrderRef" value="@brief.OrderRef" disabled="disabled" />
        </div>
    </div>
    <div class="span5">
        <div class="span3 text-right">OrderItems</div>
        <div class="span9">
            <input type="text" class="input-block-level" value="@brief.ProductName" disabled="disabled" />
        </div>
    </div>
    <div class="span4">
        <div class="span4">Despatch Date</div>
        <div class="span8">
            <input type="text" class="input-block-level" value="@brief.DespatchDate" disabled="disabled" />
        </div>
    </div>
</div>

<form action="/rdm/finaliserdm" method="POST" id="frsavedispute" class="validate fr-approverdm">
    <input type="hidden" name="DisputeID" value="@Model.DisputeID"/>
    <div class="row-fluid">
        <div class="span6">
            @Html.Action("EditRdm", "Rdm", Model)
        </div>
        <div class="span6">

            <ul class="tabs tabs-inline tabs-top orderdetail-task-tabs">
                <li class="active">
                    <a href="#Photos" data-toggle="tab">Photos</a>
                </li>
                <li>
                    <a href="#Evidence" data-toggle="tab">Other Evidence</a>
                </li>
                <li>
                        <a href="#ItemPart" data-toggle="tab" onclick="RdmOrderItemPartDetail(@Model.OrderItemID,@Model.DisputeID,$('#ItemPart'))">Order Item Part</a>
                </li>
            </ul>

            <div class="tab-content padding tab-content-inline tab-content-bottom orderdetail-task-tabs-content" style="height: 130px" id="tabOrderItemPartContet">
                <div class="tab-pane active" id="Photos">
                    <div class="rdm-tab-scroll" style="height: 130px">
                        <div class="tbl-photodispute">
                            @Html.Action("PhotosDispute", "Rdm", new { disputeid = Model.DisputeID })
                        </div>
                    </div>
                </div>
                <div class="tab-pane" id="Evidence">
                    <div class="rdm-tab-scroll" style="height: 130px">
                        <button class="btn btn-success" type="button" onclick="PopupCenter('/rdm/adddocumentdispute?disputeid=@Model.DisputeID',600,300)">Add Document</button><br />
                        <div class="tbl-document tbl-documentdispute">
                            @Html.Action("DocumentDispute", "Rdm", new { disputeid = Model.DisputeID })
                        </div>
                    </div>
                </div>
                <div class="tab-pane" id="ItemPart" style="height: 130px"></div>
            </div>
            <fieldset>
                <legend>Sign Off Details</legend>
                <div class="row-fluid">
                    <div class="span4">Action Taken</div>
                    <div class="span8">
                        @Html.DropDownList("ActionID", null, "Please select an action", new { @class = "input-block-level", required = "required", onchange = "approveactionchange(this.value)" })
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span4">Collection Items</div>
                    <div class="span8">
                        <textarea class="input-block-level" name="DisputeItems" id="DisputeItems" required="required">@Model.DisputeItems</textarea>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span4">Replacement Items</div>
                    <div class="span8">
                        <textarea class="input-block-level" name="DisputeReplacementItems" id="DisputeReplacementItems" required="required">@Model.DisputeReplacementItems</textarea>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span4">Further Details</div>
                    <div class="span8">
                        <textarea class="input-block-level" name="ActionDetails">@Model.ActionDetails</textarea>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span4">Collection Fee Required</div>
                    <div class="span1">
                        <input type="checkbox" name="CollectionFeeRequired" @(Model.CollectionFeeRequired == true ? "checked=checked" : "") />
                    </div>
                    <div class="span3">Collection Fee(£)</div>
                    <div class="span4">
                        <input type="text" class="input-block-level" name="CollectionFee" value="@string.Format("{0:0.00}", Model.CollectionFee)"  />
                    </div>
                </div>
            </fieldset>
        </div>

    </div>
    <div class="border-padding10 row-fluid" style="margin: 0">
        <div class="span4"></div>
        <div class="span2"></div>
        <div class="span3">
            @*<label>
                <input type="checkbox" name="sendingemail" value="True" style="float: left; margin-right: 10px" />
                Finalise without sending email 
            </label>*@
        </div>
        <div class="span3 text-center">
            @if (Users.Current(User.Identity.Name).HasPermission(Permissions.cannotApproveRDMs))
            {
                <button class="btn btn-primary" type="button" disabled="disabled" onclick="alert('You do not have a permission')">Finalise</button>
            }
            else
            {
                <a href="/rdm/deleterdm/@Model.DisputeID" onclick=" javascript:return confirm('Are you sure you want to delete this RDM?'); " class="btn btn-primary" style="margin-right: 10px" >Delete</a>
                <button class="btn btn-primary" type="button" onclick="CheckFinaliseRdm(@Model.DisputeID)">Finalise</button>
            }

        </div>
    </div>
</form>
